package lesson5;

public class DeadLock {

    public static void main(String[] args) {
        Object o1 = new Object();
        Object o2 = new Object();

        Runnable r1 = () ->{
            synchronized (o1){
                synchronized (o2){
                    System.out.println("r1 获得锁进行执行");
                }
            }
        };

        Runnable r2 = () ->{
            synchronized (o2){
                synchronized (o1){
                    System.out.println("r2 获得锁进行执行");
                }
            }
        };

        new Thread(r1).start();
        new Thread(r2).start();

    }
}
